package com.itbaizhan;

import java.io.FileReader;

/**
 * try-with-resource  自动动关闭Closable 接口的资源
 */
public class Test04 {
    public static void main(String[] args) {

        //在try(),在括号里的资源会自动关闭
        try(FileReader reader = new FileReader("d:/a.txt"); //可以竖排，打开多个资源
            /*FileReader reader01 = new FileReader("d:/b.txt");*/){
            char c = (char) reader.read();
            char c2 = (char) reader.read();
            char c3 = (char) reader.read();
            System.out.println("" + c + c2 + c3);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
